<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
    <meta http-equiv="expires" content="0">
    <title>购物车</title>
    <link rel="shortcut icon" href="favicon.ico" />
    <link rel="stylesheet" href="/static/css/base.css">
    <link rel="stylesheet" href="/static/css/common.css">
    <link rel="stylesheet" href="/static/css/cargo.css">
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
    <script src="/static/script/base.js"></script>
</head>

<body>
    <!-- 快捷导航模块开始 -->
    <section class="shortcut">
        <div class="width">
            <div class="fl">
                <ul>
                    <li>食品网欢迎您！&nbsp;</li>
                    <li>
                        请<a href="/loginForm" class="style_green">登录</a>
                        <a href="/registerForm" class="style_green">&nbsp;免费注册</a>
                    </li>
                </ul>
            </div>
            <div class="fr">
                <ul>
                    <li>我的订单</li>
                    <li>|</li>
                    <li>我的食品网<span></span></li>
                    <li>|</li>
                    <li>食品网会员</li>
                    <li>|</li>
                    <li>关注我们<span></span></li>
                    <li>|</li>
                    <li>客户服务<span></span></li>
                    <li>|</li>
                    <li>网站导航<span></span></li>
                </ul>
            </div>
        </div>
    </section>
    <!-- 快捷导航模块结束 -->
    <!-- 头部制作模块开始 -->
    <header class="header width">
        <a href="/index" class="logo"></a>
        <div class="search">
            <input type="search" name="" id="id_key" placeholder="中华老字号">
            <button id="id_search">搜索</button>
        </div>
        <div class="hotwords">
            <a href="/search/?keyword=%E8%91%A1%E8%90%84%E9%85%92&page=0&size=10" class="style_red">葡萄酒</a>
            <a href="/search/?keyword=%E9%A5%BC%E5%B9%B2%E8%9B%8B%E7%B3%95&page=0&size=10">饼干蛋糕</a>
            <a href="/search/?keyword=%E7%81%AB%E8%85%BF&page=0&size=10">火腿</a>
            <a href="/search/?keyword=%E9%85%92%E6%9D%AF&page=0&size=10">酒杯</a>
            <a href="/search/?keyword=%E8%86%A8%E5%8C%96%E9%A3%9F%E5%93%81&page=0&size=10">膨化食品</a>
            <a href="/search/?keyword=%E6%B0%B4%E6%9E%9C&page=0&size=10">水果</a>
            <a href="/search/?keyword=%E7%8C%AA%E8%82%89&page=0&size=10">猪肉</a>
        </div>
    </header>
    <!-- 头部制作模块结束 -->
    <!-- 右侧边栏制作开始 -->
    <div class="sidebar">
        <ul class="box">
            <li class="user" id="id_acount">
                <a href="#">
                    <span></span>
                    账号
                </a>
            </li>
            <li class="shopping_bag">
                <a href="#" id="id_cart">
                    <span></span>
                    购物车<br>
                    <i class="count">8</i>
                </a>
            </li>
            <li class="order">
                <a href="#">
                    <span></span>
                    订单
                </a>
            </li>
            <li class="collection" id="id_collection">
                <a href="#">
                    <span></span>
                    收藏
                </a>
            </li>
            <li class="complaint">
                <a href="#">
                    <span></span>
                    投诉
                </a>
            </li>
            <li class="top">
                <a href="#top">
                    <span></span>
                </a>
            </li>
        </ul>
    </div>
    <!-- 右侧边栏制作结束 -->
    <!-- 购物车列表开始 -->
    <div class="width">
        <ul class="cart_list_th">
            <li class="th_name">商品名称</li>
            <li class="th_price">价格</li>
            <li class="th_count">数量</li>
            <li class="th_sum">小计</li>
            <li class="th_op">操作</li>
        </ul>
        <div id="id_cart">
            {% for item in result %}
                <ul class="cart_list_td" gid={{ item.id }}>
                    <li class="td_img">
                        <img src={{ item.info.img }} alt="">
                    </li>
                    <li class="td_name">
                        {{item.info.title}}
                    <li>
                    <li class="td_price">{{ item.info.price }}</li>
                    <li class="td_count">{{ item.amount }}</li>
                    <li class="td_sum">{{ item.total_price }}</li>
                    <li class="td_op">
                        <span class="delete_g">删除</span>
                    </li>
                </ul>
            {% endfor %}
{#            <ul class="cart_list_td">#}
{#                <li class="td_img">#}
{#                    <img src="../static/upload/fruit5.jpg" alt="">#}
{#                </li>#}
{#                <li class="td_name">#}
{#                    海南莲雾 500g装 单果约70-130g#}
{#                </li>#}
{#                <li class="td_price">38元</li>#}
{#                <li class="td_count">1</li>#}
{#                <li class="td_sum">38元</li>#}
{#                <li class="td_op">#}
{#                    <a href="#" id="id_delete">删除</a>#}
{#                </li>#}
{#            </ul>#}
        </div>
        <ul class="settlements">
            <li class="total">
                合计(不含运费)：
                <i>¥</i>
                <span id="id_total_price"></span>
                <br>
                共计
                <em id="id_count">{{ result | length }}</em>
                件商品
            </li>
            <li class="jiesuan">
                <a href="placeOrderPage" >结算</a>
            </li>
        </ul>
    </div>
    <!-- 购物车列表结束 -->
    <!-- 底部模块开始 -->
    <footer class="footer">
        <div class="width">
            <div class="mod_service">
                <ul>
                    <li>
                        <div class="service_icon1"></div>
                        <div class="text">
                            <h3>品类齐全，轻松购物</h3>
                        </div>
                    </li>
                    <li>
                        <div class="service_icon2"></div>
                        <div class="text">
                            <h3>多仓直发，极速配送</h3>
                        </div>
                    </li>
                    <li>
                        <div class="service_icon3"></div>
                        <div class="text">
                            <h3>正品行货，精致服务</h3>
                        </div>
                    </li>
                    <li>
                        <div class="service_icon4"></div>
                        <div class="text">
                            <h3>天天低价，畅选无忧</h3>
                        </div>
                    </li>
                </ul>
            </div>
            <div class="mod_help">
                <dl>
                    <dt>
                        <a href="#">服务指南</a>
                    </dt>
                    <dd><a href="#">购物流程</a></dd>
                    <dd><a href="#">会员介绍</a></dd>
                    <dd><a href="#">生活旅行/团购</a></dd>
                    <dd><a href="#">常见问题</a></dd>
                    <dd><a href="#">联系客服</a></dd>
                </dl>
                <dl>
                    <dt><a href="#">配送方式</a></dt>
                    <dd><a href="#">上门自提</a></dd>
                    <dd><a href="#">211限时达</a></dd>
                    <dd><a href="#">配送服务查询</a></dd>
                    <dd><a href="#">配送费收取标准</a></dd>
                    <dd><a href="#">海外配送</a></dd>
                </dl>
                <dl>
                    <dt><a href="#">支付方式</a></dt>
                    <dd><a href="#">货到付款</a></dd>
                    <dd><a href="#">在线支付</a></dd>
                    <dd><a href="#">分期付款</a></dd>
                    <dd><a href="#">公司转账</a></dd>
                </dl>
                <dl>
                    <dt><a href="#">售后服务</a></dt>
                    <dd><a href="#">售后政策</a></dd>
                    <dd><a href="#">价格保护</a></dd>
                    <dd><a href="#">退款说明</a></dd>
                    <dd><a href="#">返修/退换货</a></dd>
                    <dd><a href="#">取消订单</a></dd>
                </dl>
                <dl>
                    <dt><a href="#">特色服务</a></dt>
                    <dd><a href="#">夺宝岛</a></dd>
                    <dd><a href="#">DIY装机</a></dd>
                    <dd><a href="#">延保服务</a></dd>
                </dl>
                <dl>
                    <dt>帮助中心</dt>
                    <dd class="qrcode">
                        <img src="../static/images/QRcode.png" alt="">
                    </dd>
                    下载客户端
                </dl>
            </div>
            <div class="mod_copyright">
                <div class="links">
                    <a href="#">关于我们</a>|
                    <a href="#">联系我们</a>|
                    <a href="#">联系客服</a>|
                    <a href="#">商家入驻</a>|
                    <a href="#">营销中心</a>|
                    <a href="#">友情链接</a>|
                    <a href="#">销售联盟</a>|
                    <a href="#">食品网社区</a>|
                    <a href="#">English Site</a>|
                    <a href="#">Contact U</a>|
                </div>
                <div class="copyright">
                    地址：内蒙古师范大学盛乐校区 邮编：010000 电话：400-123-1234 传真：010-12345678 邮箱: 1234567@567.com</br>
                    蒙ICP备08001234号蒙公网安备110123456789
                </div>
            </div>
        </div>
    </footer>
    <!-- 底部模块结束 -->
    <script>
        $(document).ready(function(){
            carFunction()
            calculateTotalPrice()
        });
    </script>
    <script>
        $("#id_search").click(function (){
            var key = $("#id_key").val()
            window.location.href = "/search?keyword="+key+"&page="+0+"&size="+10;
        })
    </script>
{#    删除回调事件#}
    <script>
        $('.delete_g').click(function (){
            object = $(this)
            gid = object.parent().parent().attr("gid")
            data = {"id":gid}
            $.ajax({
                url: 'delete',
                type:'POST',
                data: JSON.stringify(data),
                success:function(result){
                    object.parent().parent().remove()
                }
            })
        })
    </script>
    <script>
        var calculateTotalPrice = function () {
            var total = 0;
            $(".td_sum").each(function(){
                total+=parseFloat(this.innerText)
            })
            $("#id_total_price").text(total)
        }
    </script>
</body>

</html>